package com.jvm.interpreter.instruction;

import com.jvm.classfile.model.CpInfo;
import com.jvm.interpreter.Frame;
import com.jvm.interpreter.Instruction;

/**
 * @program: diy_simple_jvm
 * @description: iload_0指令
 * @author: CaoYong
 * @create: 2021-07-08 10:20
 **/
public class ILoad0Inst implements Instruction {

    /**
     * 将本地变量表0位置的数据取出，并推送到操作数栈栈顶
     * @param frame 栈帧
     */
    @Override
    public void eval(Frame frame) {
//        frame.operandStack.push(frame.localVars.get(0));
        frame.pushInt(frame.getInt(0));
        frame.pc += offset();
    }

    static ILoad1Inst parse(java.io.DataInputStream dis, CpInfo[] cp) throws java.io.IOException {
        return new ILoad1Inst();
    }
}
